<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

		<title><?=_("Log Manager")?></title>

		<link rel="stylesheet" type="text/css" href="/css/log.css" />
	</head>
	<body>
		<div id="page">
			<div id="p">
				<h1><?=_("Log Manager")?> &raquo; <?=_("Exceptions list")?><a href="/log/index" class="fr">&larr; <?=_("Back to home")?></a><div class="clear"></div></h1>
				<?php
				if($data->pass)
				{
					if($data->countException)
					{
						?>
						<div class="sepa10"></div>
						<h3><?=sprintf(_("%s exceptions recorded"), $data->countException)?></h3>
						<div class="sepa10"></div>
						<table cellpadding="0" cellspacing="0" border="0" width="760">
							<thead>
								<tr>
									<td class="td_mess"><?=_("Message")?></td>
									<td class="td_file"><?=_("File")?></td>
									<td class="td_line"><?=_("Line")?></td>
									<td class="td_date"><?=_("Date")?></td>
								</tr>
							</thead>
							<tbody>
								<?php
								foreach($data->listException as $exception)
								{
									?>
									<tr>
										<td class="td_mess"><span title="<?=$exception['message']?>"><?=$exception['message']?></span></td>
										<td class="td_file"><span title="<?=$exception['file']?>"><?=$exception['file']?></span></td>
										<td class="td_line"><span><?=$exception['line']?></span></td>
										<td class="td_date"><span><?=$exception['date_added']?></span></td>
									</tr>
									<?php
								}
								?>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="4">
									<?php
									$url		= '/log/exceptions?page=[page]';
									$lastpage	= ceil($data->countException / $data->logForPage);
									$adjacents	= 2;

									if ($lastpage > 1)
									{
										$lpm1 = $lastpage - 1;

										?>
										<div class="contentPagination">
											<?php
											if($lastpage > 1)
											{
												if ($data->currentPage > 1)
												{
													?><div class="itemPagination"><a href="<?=str_replace("[page]", "1", $url)?>">&laquo;</a></div><?php
												}
												else
												{
													?><div class="itemPagination">&laquo;</div><?php
												}

												if ($lastpage < 7 + ($adjacents * 2))
												{
													for ($counter = 1; $counter <= $lastpage; $counter++)
													{
														if ($counter == $data->currentPage)
														{
															?><div class="selectedPagination"><?=$counter?></div><?php
														}
														else
														{
															?><div class="itemPagination"><a href="<?=str_replace("[page]", $counter, $url)?>"><?=$counter?></a></div><?php
														}
													}
												}
												else if($lastpage > (5 + ($adjacents * 2)))
												{
													if($data->currentPage < (1 + ($adjacents * 2)))
													{
														for ($counter = 1; $counter < (4 + ($adjacents * 2)); $counter++)
														{
															if ($counter == $data->currentPage)
															{
																?><div class="selectedPagination"><?=$counter?></div><?php
															}
															else
															{
																?><div class="itemPagination"><a href="<?=str_replace("[page]", $counter, $url)?>"><?=$counter?></a></div><?php
															}
														}
														?>
														<div class="pointPagination">...</div>
														<div class="itemPagination"><a href="<?=str_replace("[page]", $lpm1, $url)?>"><?=$lpm1?></a></div>
														<div class="itemPagination"><a href="<?=str_replace("[page]", $lastpage, $url)?>"><?=$lastpage?></a></div>
														<?php
													}
													else if(($lastpage - ($adjacents * 2)) > $data->currentPage && $data->currentPage > ($adjacents * 2))
													{
														?>
														<div class="itemPagination"><a href="<?=str_replace("[page]", "1", $url)?>">1</a></div>
														<div class="itemPagination"><a href="<?=str_replace("[page]", "2", $url)?>">2</a></div>
														<div class="pointPagination">...</div>
														<?php
														for ($counter = ($data->currentPage - $adjacents); $counter <= ($data->currentPage + $adjacents); $counter++)
														{
															if ($counter == $data->currentPage)
															{
																?><div class="selectedPagination"><?=$counter?></div><?php
															}
															else
															{
																?><div class="itemPagination"><a href="<?=str_replace("[page]", $counter, $url)?>"><?=$counter?></a></div><?php
															}
														}
														?>
														<div class="pointPagination">...</div>
														<div class="itemPagination"><a href="<?=str_replace("[page]", $lpm1, $url)?>"><?=$lpm1?></a></div>
														<div class="itemPagination"><a href="<?=str_replace("[page]", $lastpage, $url)?>"><?=$lastpage?></a></div>
														<?php
													}
													else
													{
														?>
														<div class="itemPagination"><a href="<?=str_replace("[page]", "1", $url)?>">1</a></div>
														<div class="itemPagination"><a href="<?=str_replace("[page]", "2", $url)?>">2</a></div>
														<div class="pointPagination">...</div>
														<?php
														for ($counter = ($lastpage - (2 + ($adjacents * 2))); $counter <= $lastpage; $counter++)
														{
															if ($counter == $data->currentPage)
															{
																?><div class="selectedPagination"><?=$counter?></div><?php
															}
															else
															{
																?><div class="itemPagination"><a href="<?=str_replace("[page]", $counter, $url)?>"><?=$counter?></a></div><?php
															}
														}
													}
												}

												if ($data->currentPage < $counter - 1)
												{
													?><div class="itemPagination"><a href="<?=str_replace("[page]", $lastpage, $url)?>">&raquo;</a></div><?php
												}
												else
												{
													?><div class="itemPagination">&raquo;</div><?php
												}
											}
											else
											{
												?>
												<div class="itemPagination">&laquo;</div>
												<div class="selectedPagination">1</div>
												<div class="itemPagination">&raquo;</div>
												<?php
											}
											?>
										</div>
										<?php
									}
									?>
									</td>
								</tr>
							</tfoot>
						</table>
						<?php
					}
					else
					{
						?>
						<div class="sepa10"></div>
						<h3><?=_("No exceptions recorded")?></h3>
						<?php
					}
				}
				else
				{
					?><h3><?=_("The plugin not instanced before load controller")?></h3><?php
				}
				?>
			</div>
		</div>
		<div id="footer">
			<h4><?=_("Bxd framework - LOG plugin")?></h4>
		</div>
    </body>
</html>
